<template>
  <div class="box">
    <el-container>
      <el-header>
        <div>
          <p class="p1">
            <i
              class="el-icon-s-fold"
              style="font-size: 24px"
              @click="iscollapse = !iscollapse"
            ></i>
            <span style="font-size: 24px; font-weight: bold; color: darkorange"
              >阿里云</span
            >
          </p>
        </div>
        <div class="div2">
          <el-button
            @click="$router.push('/login')"
            v-if="this.$store.state.token == ''"
            >去登陆</el-button
          >
          <div v-else class="div1">
            <p>欢迎：{{ this.$store.state.user.username }}</p>
            <el-button @click="logout">退出</el-button>
          </div>
          <div>
            <el-button @click='$router.push("/cart")'>购物车</el-button>
          </div>
        </div>
      </el-header>
      <el-container>
        <el-aside :width="iscollapse ? '64px' : '200px'">
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            router
            :collapse="iscollapse"
          >
            <el-menu-item index="/home1">
              <i class="el-icon-s-home"></i>
              <span slot="title">首页</span>
            </el-menu-item>
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-goods"></i>
                <span>云服务ECS</span>
              </template>
              <el-menu-item index="/goods">
                <i class="el-icon-caret-right"></i>
                <span slot="title">实力列表</span>
              </el-menu-item>
            </el-submenu>
            <el-menu-item index="/nums">
              <i class="el-icon-menu"></i>
              <span slot="title">数据统计</span>
            </el-menu-item>
            <el-menu-item index="/index">
              <i class="el-icon-setting"></i>
              <span slot="title">系统设置</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item
              v-for="(item, index) in $route.meta.bread"
              :key="index"
              >{{ item }}</el-breadcrumb-item
            >
          </el-breadcrumb>
          <div>
            <router-view></router-view>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      iscollapse: false,
    };
  },
  mounted() {},
  methods: {
    logout() {
      this.$store.commit("logout");
    },
  },
  computed: {},
  watch: {},
};
</script>

<style lang='scss' scoped>
.box {
  width: 100%;
  .el-container {
    width: 100%;
    .el-header {
      width: 100%;
      border-bottom: 2px solid #ddd;
      display: flex;
      align-items: center;
      justify-content: space-between;
      p {
        i {
          margin-right: 10px;
        }
      }
      .div2{
        display: flex;
      }
      .div1{
        display: flex;
      }
    }
    .el-aside {
      min-height: 600px;
      border: 2px solid #ddd;
      transition: width 2s;
    }
    .el-main {
      width: 100%;
      height: 600px;
    }
  }
}
</style>